package PenTest.xiecheng.Acm1;

import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        int n = in.nextInt();
        String[] ns = new String[n];
        for (int i = 0; i < n; i++) {
            ns[i] = in.next();
        }
        for (int i = 0; i < n; i++) {
            System.out.println(calculateTimes(ns[i]));
        }
    }

    private static int calculateTimes(String str) {
        if (null == str || str.isEmpty() || str.length() == 1) {
            return 0;
        }
        int count = 0;
        int i = 0;
        while (i <= str.length() - 2) {
            if (str.charAt(i) == str.charAt(i + 1)) {
                str = str.substring(0, i) + str.substring(i + 2);
                count++;
                if (i >= 1) {
                    i--;
                }
            } else {
                i++;
            }
        }

        return count;
    }


}